package com.net;

import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;


class Student implements Comparable<Student>
{
	private String name;
	private int id;
	
	
	
	
	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	Student(String name, int id)
	{
		this.name = name;
		this.id = id;
		
	}


	@Override
	public int compareTo(Student s)
	{
		return this.id - s.id;
		
	}
}


public class TreeMapTest
{

	public static void main(String[] args)
	{
	   Student st1 = new Student("A", 8);
	   Student st2 = new Student("B", 83);
	   Student st3 = new Student("C", 81);
	   Student st4 = new Student("D", 9);
	   
	   Student st5 = new Student("E", 6);

	   TreeMap<Student, Integer> map = new TreeMap<>();
	   map.put(st1, 33);
	   map.put(st2, 33);
	   map.put(st3, 33);
	   map.put(st4, 35);
	   map.put(st5, 36);
	   
	 Iterator<Map.Entry<Student, Integer>>  it = map.entrySet().iterator();
	 
	 while(it.hasNext())
	 {
		 Map.Entry<Student, Integer> entry = it.next();
		 
		 System.out.println(entry.getKey().getId()  + "   " + entry.getKey().getName());
	 }
	 
	   
	}

}
